// controller 里面导入 model ，调用model 的方法，查询数据库
import Resources from '../modles/resourceModelSchema';
import logger from '../logger';
import url from 'url';

interface ResourcesType {
  saveResources: Function;
}
const ResourcesCtrl = <ResourcesType>{};

// 保存performance
ResourcesCtrl.saveResources = (req: any, res: any, next: Function) => {
  const queryData = url.parse(req.url, true)?.query || {};
  let { resources }: any = queryData;
  resources = JSON.parse(resources);
  Resources.create({ resources: resources.resourceData }).then((trace) => {
    res.send({
      success: true,
    });
  });
};

export default ResourcesCtrl;
